<?php
/**
 * Created by PhpStorm.
 * User: 54946
 * Date: 2017/8/8
 * Time: 22:26
 */
namespace App\Repositories;

use App\Http\Model\Search;
use Illuminate\Support\Facades\Crypt;

class SearchRepository {

    use BaseRepository;
    protected $model;

    /**
     * UserRepository constructor.
     * @param User $user
     */
    public function __construct(Search $search)
    {
        $this->model=$search;
    }

    /**
     * @param $limit
     * @return \Illuminate\Database\Query\Builder|static
     */
    public function getSearchHot($limit)
    {
        return $this->model->orderByDesc('count')->take($limit)->get();
    }

    /**
     * 热词累计
     * @param $keyWord
     * @return int
     */

    public function recordSearchKeyWord($keyWord)
    {

        return   $this->model->where('word','like','%'.$keyWord)->increment('count',1);
    }

}